<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: Ason
 * Date: 15-12-11
 * Time: 上午11:28
 * 考试系统前台控制器基类
 */
class WL_controller extends CI_Controller{

	public $data;
	
	function __construct(){
		parent::__construct();
		
		$this->load->model( 'site_model' );
		$this->load->model( 'exam_model' );
		//网站基本信息
		$this->data[ 'site' ] = $this->site_model->get_site_info();
		$setting = $this->config->item( 'exam' );
		//后台风格目录
		$this->data[ 'tpl_dir' ] = base_url(). $setting['tpl_dir'] ;
		$this->data[ 'setting' ] = $setting;
		
	}
	
	/*
	 * 用户是否已登录
	 * @return bool
	 * */
	protected function is_logged(){
		return sess( 'sid' ) ? true : false;
	}

	/**
	 * 如果用户没登录，跳转到登录页
	 * */
	public function logged_check(){
		if( !$this->is_logged() )
			redirect( '/login' );
	}
	
	/**
	 * 渲染视图
	 * @param $page string 视图文件名
	 * */
	protected function view( $page ){
		
		$this->data[ 'page' ] = $page;
		$this->load->view( 'frame', $this->data );
	}
}